package com.androidx.p013lv.mine.activity;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.mine.C1207R;
import com.androidx.p013lv.mine.adapter.AdapterAddGroup;
import com.androidx.p013lv.mine.bean.GroupBean;
import com.androidx.p013lv.mine.databinding.ActivityAddGroupBinding;
import com.androidx.p013lv.mine.dialog.AddWeChatDialog;
import com.gyf.immersionbar.ImmersionBar;
import java.util.List;

/* renamed from: com.androidx.lv.mine.activity.AddGroupActivity */
public class AddGroupActivity extends BaseActivity<ActivityAddGroupBinding> {
    String HTTP_TAG = "addGroup";
    AdapterAddGroup adapter;

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C1207R.C1212layout.activity_add_group;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        ((ActivityAddGroupBinding) this.binding).tvBack.setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.activity.AddGroupActivity.View$OnClickListenerC12181 */

            public void onClick(View view) {
                AddGroupActivity.this.finish();
            }
        });
        this.adapter = new AdapterAddGroup(getActivity());
        ((ActivityAddGroupBinding) this.binding).gridView.setAdapter((ListAdapter) this.adapter);
        ((ActivityAddGroupBinding) this.binding).gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            /* class com.androidx.p013lv.mine.activity.AddGroupActivity.C12192 */

            @Override // android.widget.AdapterView.OnItemClickListener
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                int groupType = AddGroupActivity.this.adapter.getItem(i).getGroupType();
                if (groupType == 1 || groupType == 2) {
                    AddGroupActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(AddGroupActivity.this.adapter.getItem(i).getLink())));
                } else if (groupType == 3) {
                    AddGroupActivity addGroupActivity = AddGroupActivity.this;
                    addGroupActivity.joinQQGroup(addGroupActivity.adapter.getItem(i).getLink());
                } else if (groupType == 4) {
                    AddGroupActivity addGroupActivity2 = AddGroupActivity.this;
                    addGroupActivity2.startWx(addGroupActivity2.adapter.getItem(i).getLink());
                }
            }
        });
        addGroupData();
    }

    public void startWx(String str) {
        AddWeChatDialog addWeChatDialog = new AddWeChatDialog(this);
        addWeChatDialog.setWeChatCodeUrl(str);
        addWeChatDialog.show();
    }

    public void joinQQGroup(String str) {
        Intent intent = new Intent();
        intent.setData(Uri.parse("mqqapi://card/show_pslcard?src_type=internal&version=1&uin=" + str + "&card_type=group&source=external"));
        try {
            startActivity(intent);
        } catch (Exception unused) {
            ToastUtils.getInstance().showSigh("未安裝QQ或安裝的版本不支持");
        }
    }

    public void addGroupData() {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().addGroup(), new HttpCallback<BaseRes<List<GroupBean>>>(this.HTTP_TAG, this) {
            /* class com.androidx.p013lv.mine.activity.AddGroupActivity.C12203 */

            public void onLvSuccess(BaseRes<List<GroupBean>> baseRes) {
                if (baseRes.getCode() != 200) {
                    ToastUtils.getInstance().showWeak(baseRes.getMsg());
                } else if (baseRes.getData() == null || baseRes.getData().size() <= 0) {
                    ToastUtils.getInstance().showWeak("暫無福利群");
                } else {
                    AddGroupActivity.this.adapter.setList(baseRes.getData());
                }
            }
        });
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityAddGroupBinding) this.binding).toolbar).init();
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        super.onDestroy();
        HttpUtils.getInsatance().cancelTag(this.HTTP_TAG);
    }
}
